__________________________________________________________________________________________________
sample 0 ms submission
class Solution {
public:
    int countLetters(string S) {
        S += "#";
        int i = 0, n = S.length(), ans = 0;
        for(int j = 0; j < n; ++j) {
            if (S[j] != S[i]) {
                int cnt = j - i;
                ans += cnt * (cnt + 1) / 2;
                i = j;
            }
        }
        
        return ans;
    }
};
__________________________________________________________________________________________________

__________________________________________________________________________________________________
